package com.example.technologyintroandroid;

import sheep.game.Sprite;
import sheep.graphics.Image;

public class Helicopter2 extends Sprite{
	
	private int width, height, speedX = 40, speedY = 40;
	private boolean moveRight, moveLeft, moveUp, moveDown;
	
	public Helicopter2(Image image, int width, int height){
		super(image);
		this.width = width;
		this.height = height;
		this.setPosition(width/2, height/2);
		moveRight = false;
		moveDown = false;
		moveUp = false;
		moveLeft = false;
		
		this.setSpeed(-speedX, speedY);
	}
	
	public void setMoveRight(boolean moveRight) {
		this.moveRight = moveRight;
	}

	public void setMoveLeft(boolean moveLeft) {
		this.moveLeft = moveLeft;
	}

	public void setMoveUp(boolean moveUp) {
		this.moveUp = moveUp;
	}

	public void setMoveDown(boolean moveDown) {
		this.moveDown = moveDown;
	}
	
	public void setAllMoves(boolean boo){
		this.moveDown = boo;
		this.moveLeft = boo;
		this.moveRight = boo;
		this.moveUp = boo;
	}

	@Override
	public void update(float dt) {
		super.update(dt);
		if(this.getPosition().getX()<=100){
			this.setSpeed(speedX, this.getSpeed().getY());
			this.setScale(-1, 1);
			this.setPosition(200, this.getPosition().getY());
		}
		if (this.getPosition().getX()>=width-70){
			this.setSpeed(-speedX, this.getSpeed().getY());
			this.setScale(1, 1);
			this.setPosition(width-75, this.getPosition().getY());
		}
		if(this.getPosition().getY()<=30){
			this.setSpeed(this.getSpeed().getX(), speedY);
		}
		if(this.getPosition().getY()>=height-70){
			this.setSpeed(this.getSpeed().getX(), -speedY);
		}
		if(moveDown){
			this.setSpeed(this.getSpeed().getX(), speedY);
		}
		if(moveUp){
			this.setSpeed(this.getSpeed().getX(), -speedY);
		}
		if(moveRight){
			this.setSpeed(speedX, this.getSpeed().getY());
			this.setScale(-1, 1);
		}
		if(moveLeft){
			this.setSpeed(-speedX, this.getSpeed().getY());
			this.setScale(1, 1);
		}
	}
}
